<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019\6\16 0016
 * Time: 14:49
 */


/**
 * 原型模式   避免多次new对象而占用太多资源，用户clone对象来避免多次初始化
 */
//$canvas = new \BigVideo\IMooc\Canvas\Canvas();
//$canvas->init();
//$canvas1 = clone $canvas;
//$canvas1->rect(4,8,2,7);
//$canvas1->draw();
//
//$canvas2 = clone $canvas;
//$canvas2->rect(6,9,3,6);
//$canvas2->draw();

/**
 * 装饰器模式的调用实例-----功能多的时候采用装饰器
 */
$canvas = new \BigVideo\IMooc\Canvas\Canvas();
$canvas->init();
$canvas->addDecorator(new ColorDrawDecorator("green"));
$canvas->addDecorator(new SizeDrwaDecorator("15px"));
$canvas->rect(3,6,6,9);
$canvas->draw();